<?php 
namespace app\common\model;
class MemberBouns extends Common{
	protected $insert = ['addtime'=>SYS_TIME];

	protected function getAlldataAttr($value, $data){
		$arr = [0=>'待发放',1=>'已发放',2=>'已确认'];
		$adminuser = '--';
		if ($data['adminid']) {
			$ainfo = model('AdminUser')->field('username,realname')->where('userid', $data['adminid'])->find();
			$adminuser = $ainfo['realname'] ?: $ainfo['username'];
		}
        $data['realname'] = $this->Adminuser['realname'] ?: $this->Adminuser['username'];
        $data['clientname'] = $this->client['name'];
        $data['statusname'] = $arr[$data['status']];
        $data['adminuser'] = $adminuser;
        $data['senddate'] = $data['sendtime'] ? date('Y-m-d H:i:s', $data['sendtime']) : '待发放';
        $data['auditdate'] = $data['audittime'] ? date('Y-m-d H:i:s', $data['audittime']) : '未确认';
        $data['adddate'] = $data['addtime'] ? date('Y-m-d H:i:s', $data['addtime']) : '未设置';
        trace($data);
        return $data;
    }


	public function Adminuser()
    {
        return $this->belongsTo('AdminUser', 'userid', 'userid', [], 'LEFT')->setEagerlyType(0);
    }

    public function client()
    {
        return $this->belongsTo('Client', 'clientid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}